#include <memento_pattern.h>

Memento::Memento(string state)
{
    this->state = state;
}

string Memento::getState()
{
    return this->state;
}

void Originator::setState(string state)
{
    this->state = state;
}

string Originator::getState()
{
    return this->state;
}

Memento* Originator::saveStateToMemento()
{
    return new Memento(this->state);
}

void Originator::getStateFromMemento(Memento *memento)
{
    this->state = memento->getState();
}

CareTaker::~CareTaker()
{
    vector<Memento*>::iterator it = mementoList.begin();
    for(; it != mementoList.end(); it++)
    {
        delete *it;
    }
}

void CareTaker::add(Memento *state)
{
    this->mementoList.push_back(state);
}

Memento* CareTaker::get(int index)
{
    return this->mementoList[index];
}
